/*
ID: guoxu1
PROG: crypt1
LANG: C++
*/
#include <fstream>
#include <set>
using namespace std;

#define cin fin
#define cout fout

inline bool digitin( bool digits[9], int digit )
{
  if( digit == 0 ) return false;
  return digits[ digit - 1 ]; 
}

bool check( bool digits[9], int number, int count )
{
  while( number > 0 )
  {
    if( !digitin( digits, number % 10 ) )
    {
      return false;
    }
    number /= 10;
    count--;
  }
  if( count < 0 ) return false;
  else return true;
}

int main()
{
  ifstream fin( "crypt1.in" );
  ofstream fout( "crypt1.out" );

  bool digits[9] = { false };
  int count = 0;
  cin >> count;
  for( int i = 0; i < count; i++ )
  {
    int digit = 0;
    cin >> digit;
    digits[ digit - 1 ] = true;
  }

  int solutions = 0;
  for( int a = 100; a < 1000; a++ )
  {
    if( !check( digits, a, 3 ) ) continue;
    for( int b = 10; b < 100; b++ )
    {
      if( !check( digits, b, 2 ) ) continue;
      if( !check( digits, a * ( b % 10 ), 3 ) ) continue;
      if( !check( digits, a * ( b / 10 ), 3 ) ) continue;
      if( !check( digits, a * b, 4 ) ) continue;
      solutions++;
    }
  }

  cout << solutions << endl;

  return 0;
}
